<div class="page-header position-relative">
	<h1>
		Cập Nhật Sản Phẩm
	</h1>
</div>
<div class="row-fluid">
	<div class="span12">
		<!--PAGE CONTENT BEGINS-->
		<?php
		$form = $this->beginWidget('CActiveForm', array(
                'id' => 'product-form',
//            'enableAjaxValidation' => false,
                'enableClientValidation' => true,
                'htmlOptions' => array(
                    'class' => 'form-horizontal',
                    'enctype' => 'multipart/form-data',
                    ),
                ));
		?>
		<div class="control-group">
				<?php echo $form->label($model,'Mã Sản Phẩm',array('class' => 'control-label')); ?>
				<div class="controls">
					<?php echo $form->textField($model, 'ProductId', array('size' => 60, 'maxlength' => 10,'class'=>'span5','placeholder' => 'Mã Sản Phẩm')); ?>
                	<span class="help-inline"><?php echo $form->error($model, 'ProductId'); ?></span>
				</div>
			</div>

			<div class="control-group">
				<?php echo $form->label($model,'Tên Sản Phẩm',array('class' => 'control-label')); ?>
				<div class="controls">
					<?php echo $form->textField($model, 'ProductName', array('size' => 60, 'maxlength' => 255,'class'=>'span5','placeholder' => 'Tên Sản Phẩm')); ?>
                	<span class="help-inline"><?php echo $form->error($model, 'ProductName'); ?></span>
				</div>
			</div>

			<div class="control-group">
				<?php echo $form->label($model,'Thể Loại',array('class' => 'control-label')); ?>
				<div class="controls">
					<?php echo $form->dropDownlist($model, 'GenreId', MyFunctionCustom::getDropdownlistGenre()); ?>
				</div>
				 <?php echo $form->error($model,'GenreId'); ?>
			</div>

			<div class="control-group">
				<?php echo $form->label($model,'Danh Mục',array('class' => 'control-label')); ?>
				<div class="controls">
					<?php echo $form->dropDownlist($model, 'CategoryId', MyFunctionCustom::getDropdownlistCategory()); ?>
				</div>
				 <?php echo $form->error($model,'CategoryId'); ?>
			</div>

			<div class="control-group">
				<?php echo $form->label($model,'Loại Danh Mục',array('class' => 'control-label')); ?>
				<div class="controls">
					<?php echo $form->dropDownlist($model, 'SubCategoryId', MyFunctionCustom::getDropdownlistSubCategory()); ?>
				</div>
				 <?php echo $form->error($model,'SubCategoryId'); ?>
			</div>

			<div class="control-group">
				<?php echo $form->label($model,'Kiểu Sản Phẩm',array('class' => 'control-label')); ?>
				<div class="controls">
					<?php echo $form->dropDownlist($model, 'SubSubCateId', MyFunctionCustom::getDropdownlistSubSubCategory()); ?>
				</div>
				 <?php echo $form->error($model,'SubSubCateId'); ?>
			</div>

			<div class="control-group">
				<?php echo $form->label($model,'Thương Hiệu',array('class' => 'control-label')); ?>
				<div class="controls">
					<?php echo $form->dropDownlist($model, 'BrandId', MyFunctionCustom::getDropdownlistBrand()); ?>
				</div>
				 <?php echo $form->error($model,'BrandId'); ?>
			</div>

			<div class="control-group">
				<?php echo $form->label($model,'Màu Sắc',array('class' => 'control-label')); ?>

				<div class="controls">
					<?php echo $form->dropDownlist($model, 'ColorId', MyFunctionCustom::getDropdownlistColor());?>
                	<span class="help-inline"><?php echo $form->error($model, 'CategoryId'); ?></span>
				</div>
			</div>
			
			<div class="control-group">
				<?php echo $form->label($model,'Kích Cỡ',array('class' => 'control-label')); ?>

				<div class="controls">
					<?php echo $form->dropDownlist($model, 'SizeId', MyFunctionCustom::getDropdownlistSize());?>
                	<span class="help-inline"><?php echo $form->error($model, 'Status'); ?></span>
				</div>
			</div>			

			<div class="control-group">
				<?php echo $form->label($model,'Giá',array('class' => 'control-label')); ?>

				<div class="controls">
					<?php echo $form->textField($model, 'Price', array('size' => 60, 'maxlength' => 255,'class'=>'span5','placeholder' => 'Giá Sản Phẩm')); ?>
                	<span class="help-inline"><?php echo $form->error($model, 'Price'); ?></span>
				</div>
			</div>

			<div class="control-group">
				<?php echo $form->label($model,'Giá Giảm',array('class' => 'control-label')); ?>

				<div class="controls">
					<?php echo $form->textField($model, 'PriceOff', array('size' => 60, 'maxlength' => 255,'class'=>'span5','placeholder' => 'Giá Giảm Sản Phẩm')); ?>
                	<span class="help-inline"><?php echo $form->error($model, 'PriceOff'); ?></span>
				</div>
			</div>

			<div class="control-group">
				<?php echo $form->label($model,'Tỷ Lệ Giảm (%)',array('class' => 'control-label')); ?>

				<div class="controls">
					<?php echo $form->textField($model, 'PriceOffPercent', array('size' => 60, 'maxlength' => 255,'class'=>'span5','placeholder' => 'Tỷ Lệ Giảm Sản Phẩm')); ?>
                	<span class="help-inline"><?php echo $form->error($model, 'PriceOffPercent'); ?></span>
				</div>
			</div>

			<div class="control-group">
				<?php echo $form->label($model,'Số Lượng',array('class' => 'control-label')); ?>

				<div class="controls">
					<?php echo $form->textField($model, 'Quantity', array('size' => 60, 'maxlength' => 255,'class'=>'span5','placeholder' => 'Số Lượng Sản Phẩm')); ?>
                	<span class="help-inline"><?php echo $form->error($model, 'Quantity'); ?></span>
				</div>
			</div>

			<div class="control-group">
				<?php echo $form->label($model,'Đơn Vị Tính',array('class' => 'control-label')); ?>

				<div class="controls">
					<select class="span3" name="Product[Unit]">
						<option value="VND">VND</option>
					</select>
                	<span class="help-inline"><?php echo $form->error($model, 'Unit'); ?></span>
				</div>
			</div>

			<div class="control-group">
				<?php echo $form->label($model,'Trạng Thái',array('class' => 'control-label')); ?>

				<div class="controls">
					<?php echo $form->dropDownlist($model, 'Status', array('0' => 'Không kích hoạt','1'=>'Kích hoạt')); ?>
                	<span class="help-inline"><?php echo $form->error($model, 'Status'); ?></span>
				</div>
			</div>

			<div class="control-group">
                    <?php echo $form->labelex($model, 'Hình Đại Diện', array('class' => 'control-label')); ?>
                    <div class="controls">
                        <?php echo $form->fileField($model, 'CoverPhoto', array('class' => 'id-input-file-1 span5')); ?>
                        <span class="help-inline" style="float:left;margin-left:390px;"><?php echo $form->error($model, 'CoverPhoto'); ?></span>
                    </div>
                </div>
            <div class="control-group">
                    <?php echo $form->labelex($model, 'Hình Ảnh', array('class' => 'control-label')); ?>
                    <div class="controls">
                        <div  id="gallary-tmp" style="margin-bottom:10px;">
                            <?php if($model->GalleryId !=''): 
                                 $gallery = Item::model()->with('gallery')->findByAttributes(array('GalleryId'=>$model->GalleryId));
                                 if($gallery):
                            ?>
                            <img src="<?php echo Yii::app()->baseUrl; ?>/timthumb.php?src=<?php echo Yii::app()->baseUrl; ?>/images/products/<?php echo $gallery->ItemName; ?>&h=150&w=150" />
                            <?php endif;endif; ?>
                        </div>
                         <?php echo $form->hiddenField($model,'GalleryId');?>
                         <?php //echo $form->hiddenField($model,'tmpGallery');?>
                        <a href="#modal-form" role="button" class="blue" data-toggle="modal">
                           <button class="btn btn-small btn-primary">Choose Gallery</button>
                        </a>
                        <span class="help-inline"><?php echo $form->error($model, 'GalleryId'); ?></span>
                    </div>
                </div>

			<div class="control-group">
				<?php echo $form->label($model,'Mô Tả',array('class' => 'control-label')); ?>

				<div class="controls">
					<?php //echo $form->textField($model, 'Descriptions', array('size' => 60, 'maxlength' => 255,'class'=>'span5','placeholder' => 'Mô Tả Sản Phẩm')); ?>
                	<span class="help-inline"><?php echo $form->error($model, 'Descriptions'); ?></span>
				</div>
			</div>

			<?php
                $this->widget('ext.editMe.ExtEditMe', array(
                    'model' => $model,
                    'height' => '250px',
                    'width' => '100%',
                    'attribute' => 'Descriptions',
                    'toolbar' => Yii::app()->params['ckeditor'],
                    'filebrowserBrowseUrl' => Yii::app()->baseUrl . '/ckfinder/ckfinder.html',
                    'filebrowserImageBrowseUrl' => Yii::app()->baseUrl . '/ckfinder/ckfinder.html?type=Images',
                    'filebrowserFlashBrowseUrl' => Yii::app()->baseUrl . '/ckfinder/ckfinder.html?type=Flash',
                    'filebrowserUploadUrl' => Yii::app()->baseUrl . '/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Files',
                    'filebrowserImageUploadUrl' => Yii::app()->baseUrl . '/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Images',
                    'filebrowserFlashUploadUrl' => Yii::app()->baseUrl . '/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Flash',
                ));
                ?>

			<div class="form-actions">
				<button class="btn btn-info" type="submit">
					<i class="icon-ok bigger-110"></i>
					Submit
				</button>

				&nbsp; &nbsp; &nbsp;
				<button class="btn" type="reset">
					<i class="icon-undo bigger-110"></i>
					Reset
				</button>
			</div>

		<?php $this->endWidget(); ?>
		</div>
		</div>
<script src="<?php echo Yii::app()->theme->baseUrl; ?>/backend/tag/bootstrap-tagsinput.js"></script>
<link rel="stylesheet" href="<?php echo Yii::app()->theme->baseUrl; ?>/backend/tag/bootstrap-tagsinput.css">
<style>
    .control-group span.required,.errorMessage {color:red;}
    .bootstrap-tagsinput {width:365px;margin-top:5px;}
    .ace-file-input {width: 380px;height: auto;}

</style>

<?php echo $this->renderPartial('_popup', array('model'=>$model)); ?>
		